package com.erp.order.purchasing.controller;

import com.erp.hr.base.controller.BaseController;
import com.erp.masterdata.material.dao.model.MdMaterialCO;
import com.erp.order.purchasing.service.OtherService;
import com.erp.order.purchasing.service.PurchasingRequisitionService;
import org.redragon.framework.hibernate.model.Pages;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 乱七八糟 控制层
 * @Author: syz
 * @blame syz
 * @CreateTime: 2021/4/6
 */
@Controller
@RequestMapping("web/other")
public class OtherController extends BaseController {

    private Logger logger = LoggerFactory.getLogger(OtherController.class);

    /**
     * 乱七八糟服务
     */
    @Autowired
    private OtherService otherService;

    /**
     * 采购申请服务
     */
    @Autowired
    private PurchasingRequisitionService purchasingRequisitionService;


    /**
     * 获取物资集合
     * @param pages 分页对象
     * @param mdMaterial 物资对象
     * @param model 模型对象
     * @return 物资集合
     */
    @RequestMapping("getMaterialList")
    public String getMaterialList(Pages pages, MdMaterialCO mdMaterial, Model model) {
        model.addAttribute("pages", setPages(pages));
        model.addAttribute("list", otherService.getMaterialList(pages, mdMaterial));
        model.addAttribute("unitMap", purchasingRequisitionService.getDictByKey("material_unit"));
        return "purchasingRequisition/material";
    }

}